package dang.action.user;

import java.text.SimpleDateFormat;
import java.util.Date;

import dang.action.DangAction;
import dang.entity.User;

public class LoginInfoAction extends DangAction{
	private boolean loggedIn;
	private String nickname;
	private String last_login_time;
	private String last_login_ip;
	public String execute(){
		if(session.get("user")!=null){
			User user=(User)session.get("user");
			nickname=user.getNickname();
			last_login_ip=user.getLast_login_ip();
			long time=user.getLast_login_time();
			if(time!=0){
				SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				last_login_time=sdf.format(new Date(time));
			}else{
				last_login_time="0";
			}
			
			loggedIn=true;
		}
		return "success";
	}
	public boolean isLoggedIn() {
		return loggedIn;
	}
	public void setLoggedIn(boolean loggedIn) {
		this.loggedIn = loggedIn;
	}
	public String getNickname() {
		return nickname;
	}
	public void setNickname(String nickname) {
		this.nickname = nickname;
	}
	public String getLast_login_ip() {
		return last_login_ip;
	}
	public void setLast_login_ip(String lastLoginIp) {
		last_login_ip = lastLoginIp;
	}
	public String getLast_login_time() {
		return last_login_time;
	}
	public void setLast_login_time(String lastLoginTime) {
		last_login_time = lastLoginTime;
	}
}
